<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>滴答办公系统-员工列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/media/layui/css/layui.css" media="all">
<script src="/media/js/jquery.min.js"></script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>工号</td>
					<td>姓名</td>
					<td>部门</td>
					<td>性别</td>
					<td>手机号</td>
					<td>QQ号</td>
					<td>邮箱</td>
					<td>入职日期</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${pageUtils.recordsl}" var="emp">
					<tr>
						<td>${emp.id}</td>
						<td>${emp.no}</td>
						<td>${emp.name}</td>
						<td>${emp.depart.name}</td>
						<td>${emp.sex}</td>
						<td>${emp.phone}</td>
						<td>${emp.qq}</td>
						<td>${emp.email}</td>
						<td>${emp.createdate}</td>
						<td><a class="layui-btn layui-btn-mini" href="empupdate.html">编辑</a>
							<a class="layui-btn layui-btn-danger layui-btn-mini"
							   lay-event="del" onclick="deleteCourse(${emp.id},${pageUtils.pageIndex},${pageUtils.pageSize});">删除</a></td>
					</tr>
				</c:forEach>

			</tbody>

		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
			              <c:if test="${pageUtils.pageIndex==1}">
							  <a href="#"
								 class="layui-laypage-prev layui-disabled" data-page="0">
								  <i class="layui-icon">&lt;</i>
							  </a>
						  </c:if>
			              <c:if test="${pageUtils.pageIndex!=1}">
							  <a href="/empPageList/${pageUtils.pageIndex-1}/${pageUtils.pageSize}"
							  class="layui-laypage-prev" data-page="0">
								  <i class="layui-icon">&lt;</i>
							  </a>
						  </c:if>

                            <c:forEach begin="${pageUtils.numberStart}" end="${pageUtils.numberEnd}" var="num" step="1">
                                <a href="/empPageList/${num}/${pageUtils.pageSize}">${num}</a>
                            </c:forEach>

			                <c:if test="${pageUtils.pageIndex==pageUtils.pageCount}">
								<a href="#"
								   class="layui-laypage-next layui-disabled" data-page="2">
									<i class="layui-icon">&gt;</i>
								</a>
							</c:if>

			               <c:if test="${pageUtils.pageIndex!=pageUtils.pageCount}">
							   <a href="/empPageList/${pageUtils.pageIndex+1}/${pageUtils.pageSize}"
								  class="layui-laypage-next " data-page="2">
								   <i class="layui-icon">&gt;</i>
							   </a>
						   </c:if>

							<span class="layui-laypage-skip">到第
							   <input type="text" min="1" value="${pageUtils.pageIndex}" class="layui-input">页
								<button type="button" class="layui-laypage-btn" onclick="pageBtn()">确定</button>
							</span> 
							<span class="layui-laypage-count">共 ${pageUtils.allCount} 条  当前第${pageUtils.pageIndex}页/共${pageUtils.pageCount}页</span>
							<span class="layui-laypage-limits"> 
							    <select lay-ignore="" onchange="toPage(this)">
							        <option value="5" ${pageUtils.pageSize==5?"selected":""}>5 条/页</option>
									<option value="10" ${pageUtils.pageSize==10?"selected":""}>10 条/页</option>
									<option value="20" ${pageUtils.pageSize==20?"selected":""}>20 条/页</option>
							</select>
							</span>
						</div>
	</div>
	
	<script src="/media/layui/layui.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.4.3/layui.all.js"></script>
	
	<script type="text/javascript">
	   function deleteCourse(id,ind,size){
		   layui.use('table', function() {
			   layer.confirm('是否确认删除员工?',function(index) {
				   $.getJSON("/deletedemp",{"id":id},function (result) {
					   if (result.status == 200) {
						   layer.msg(result.message);
						   setTimeout(function () {
							   location.href ="/empPageList/"+ind+"/"+size
						   }, 600);
					   }else {
						   layer.msg(result.message);
					   }
				   });
			   });
		   });
	   }
	</script>
<script>
	// 分页大小调整
	function toPage(th) {
		location.href="/empPageList/1/"+th.value;
	}
	//按钮跳转页面
	function pageBtn() {
		if($('#pageText').val() <= ${pageUtils.pageCount}){
			location.href="/empPageList/"+$('#pageText').val()+"/"+$("select").val();
		}else{
			layer.msg("请重新输入");
			$('#pageText').val("")
		}

	}
</script>

</body>
</html>